package com.learn.queue.unsafe;

import java.util.LinkedList;
import java.util.Queue;

/**
 * 测试LinkedList
 */
public class LinkedListTest {

    public static void main(String args[]){
        Queue<Integer> queue = new LinkedList<>();
        //进队
        queue.offer(1);
        queue.offer(2);
        queue.offer(3);
        queue.offer(4);

        // 循环打印
        queue.forEach(integer -> System.out.print(integer + "-"));

        System.out.println();
        System.out.println("------------------------");

        //获取第一个元素并删除
        System.out.println("poll=" + queue.poll());

        // 循环打印
        queue.forEach(integer -> System.out.print(integer + "-"));

        System.out.println();
        System.out.println("------------------------");

        //获取第一个元素
        System.out.println("element=" + queue.element());
        // 循环打印
        queue.forEach(integer -> System.out.print(integer + "-"));

        System.out.println();
        System.out.println("------------------------");

        //获取第一个元素
        System.out.println("peek=" + queue.peek());

        // 循环打印
        queue.forEach(integer -> System.out.print(integer + "-"));
    }
}
